package com.rabbit.controller;

import com.rabbit.exception.BusinessException;
import com.rabbit.service.LoginService;
import com.rabbit.util.ResultGenUtil;
import com.rabbit.vo.ResultVO;
import com.rabbit.vo.req.LoginReq;
import com.rabbit.vo.res.LoginRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zjw
 * @date 2022/6/22 15:23
 */
@Api(tags = "登录模块")
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    @ApiOperation(value = "login", response = ResultVO.class, httpMethod = "POST")
    @PostMapping("/login")
    public ResultVO<Object> login(@Validated @RequestBody LoginReq loginReq) throws BusinessException {
        LoginRes loginRes = loginService.login(loginReq);
        return ResultGenUtil.genSuccess(loginRes);
    }

}
